﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ru">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Административный интерфейс</title>
	<meta http-equiv="Expires" content="0">
	<meta http-equiv="Pragma" content="no-cache">
	<meta http-equiv="Set-Cookie" content="siteadmin=1; EXPIRES=Monday, 21-SEP-09 21:11:51 GMT; PATH=/;">
	<link rel="shortcut icon" href="images/favicon.ico">
	<link rel="stylesheet" href="css/style.css" type="text/css">
	<link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.7.2.custom.css" type="text/css" >
	<script type="text/javascript" src="js/jquery-1.3.2.min.js" language="JavaScript"></script>
	<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js" language="JavaScript"></script>
	<script type="text/javascript" src="js/jsibox_basic.js" language="JavaScript"></script>
</head>
<body>
{include file="tinymce_full_tpl.html"}
{literal}
<style type="text/css">
	#sortable { list-style-type: none; margin: 0; padding: 0;}
	#sortable li { margin: 0px 3px 3px 0; padding: 1px; float: left; text-align: left;}
</style>
<script type="text/javascript">
	$(function() {
		$("#sortable").sortable();
		$("#sortable").disableSelection();
		$("#dlgSelectGallery").dialog({
			bgiframe: true,
			height: 270,
			width: 400,
			modal: true,
			autoOpen: false
		});
	});
var uploadImgCount = 1;
function openFileDialog(obj)
{
{/literal}
	var str = '<table border="0" cellpadding="0" cellspacing="2" id="uploadTbl##NUM##"><tr><td width="110">Добавить картинку:</td><td><input type="file" size="47" name="userfile##NUM##" style="width: 100%;" onchange="openFileDialog(this)"></td><td width="130"><label for="mus##NUM##">Наложить мал. маску</label><input type="checkbox" name="mus##NUM##" value="1" id="mus##NUM##" {if $smarty.cookies.mask_small eq 1}checked="checked"{/if}></td><td width="160">Размер: <input type="text" size="5" name="swidth_##NUM##" value="{$SIZE_S_W}"> px X <input type="text" size="5" name="sheight_##NUM##" value="{$SIZE_S_H}"> px</td></tr>	<tr><td>Alt. текст:</td><td><input type="text" name="alt_text##NUM##" size="60" maxlength="255" style="width: 100%;"></td><td><label for="mum##NUM##">Наложить сред. маску</label><input type="checkbox" name="mum##NUM##" value="1" id="mum##NUM##" {if $smarty.cookies.mask_medium eq 1}checked="checked"{/if}></td><td width="160">Размер: <input type="text" size="5" name="mwidth_##NUM##" value="{$SIZE_M_W}"> px X <input type="text" size="5" name="mheight_##NUM##" value="{$SIZE_M_H}"> px</td></tr><tr><td>Описание:</td><td><input type="text" name="description##NUM##" size="60" maxlength="255" style="width: 100%;"></td><td><label for="mub##NUM##">Наложить бол. маску</label><input type="checkbox" name="mub##NUM##" value="1" id="mub##NUM##" {if $smarty.cookies.mask_native eq 1}checked="checked"{/if}></td><td width="160">Размер: <input type="text" size="5" name="bwidth_##NUM##" value="{$SIZE_B_W}"> px X <input type="text" size="5" name="bheight_##NUM##" value="{$SIZE_B_H}"> px</td></tr></table>';
{literal}
	var re = /##NUM##/g;
	str = str.replace(re, uploadImgCount);
	var curTblId = "uploadTbl"+(uploadImgCount-1);
	uploadImgCount++;
	$("#"+curTblId).after(str);
	obj.onchange=null;
}
function saveOrder()
{
	var result = $('#sortable').sortable('toArray');
	{/literal}
	location.href="index.php?module=gallery&action=SAVEORDER&id={$id}&ord="+result;
	{literal}
	return false;
}
function CopyImages()
{
	$("#ifrmGallery").attr('src','index.php?module=gallery');
	$("#dlgSelectGallery").dialog('open');
	return false;
}
/* Вызывается document'ом в iframe, когда документ загрузился. 
Кол-во аргументов произвольное-зависит от модуля
*/
function PageLoaded()
{
	win = arguments[0]?arguments[0]:null;
	module = arguments[1]?arguments[1]:'';
	if (module=='gallery')
	{
		sel = arguments[2]?arguments[2]:'';
		if (sel=='selected')
		{
			for (i = 0; i < win.document.forms['main'].elements.length; i++)
			{
				var item = win.document.forms['main'].elements[i];
				if ((item.name == "id[]") && (item.checked))
				{
					f = document.forms['items'];
					f.action = 'index.php?module=gallery&action=copyimages&fixact=1&id='+item.value;
					f.submit();
					//itemcard.OnGallerySelected(item.value);
					break;
				}
			}
		}
		else
		{
			win.document.write('<button onclick="parent.PageLoaded(window,\'gallery\',\'selected\');">OK</button>');
		}
	}
}
</script>
{/literal}
<fieldset class="groupbox">
    <legend>Галерея изображений {$id}</legend>
    
    {if $id neq null}
<form action="index.php?module=gallery&action=addgalitem&fixact=1&id={$id}" method="post" enctype="multipart/form-data">
	<table border="0" cellpadding="0" cellspacing="2" id="uploadTbl0">
	<tr><td width="110">Добавить картинку:</td><td><input type="file" size="47" name="userfile0" style="width: 100%;" onchange="openFileDialog(this)"></td><td width="130"><label for="mus0">Наложить мал. маску</label><input type="checkbox" name="mus0" value="1" id="mus0" {if $smarty.cookies.mask_small eq 1}checked="checked"{/if}></td>
	<td width="160">Размер: <input type="text" size="5" name="swidth_0" value="{$SIZE_S_W}"> px X <input type="text" size="5" name="sheight_0" value="{$SIZE_S_H}"> px</td></tr>
	
	<tr><td>Alt. текст:</td><td><input type="text" name="alt_text0" size="60" maxlength="255" style="width: 100%;"></td><td><label for="mum0">Наложить сред. маску</label><input type="checkbox" name="mum0" value="1" id="mum0" {if $smarty.cookies.mask_medium eq 1}checked="checked"{/if}></td>
	<td width="160">Размер: <input type="text" size="5" name="mwidth_0" value="{$SIZE_M_W}"> px X <input type="text" size="5" name="mheight_0" value="{$SIZE_M_H}"> px</td>
	</tr>
	<tr><td>Описание:</td><td><input type="text" name="description0" size="60" maxlength="255" style="width: 100%;"></td><td><label for="mub0">Наложить бол. маску</label><input type="checkbox" name="mub0" value="1" id="mub0" {if $smarty.cookies.mask_big eq 1}checked="checked"{/if}></td>
	<td width="160">Размер: <input type="text" size="5" name="bwidth_0" value="{$SIZE_B_W}"> px X <input type="text" size="5" name="bheight_0" value="{$SIZE_B_H}"> px</td>
	</tr>
	</table>
	<input type="submit" value="Добавить">
</form>

	{gallery action="GETGALITEMS" id=$id varname="items"}
	<hr>
	Картинки в галерее:<br>
<form action="index.php?module=gallery&action=delitem&fixact=1&id={$id}" method="post" name="items">

<ul id="sortable">
{foreach from=$items item=pic name=items}
<li id="{$pic.id}"><input type="checkbox" name="itemId[]" value="{$pic.id}"><a href="index.php?module=gallery&action=editgalitem&fixact=0&id={$pic.id}&galid={$id}"><img src="images/b_edit.png" width="16" height="16" alt="Редактировать" border="0" align="absmiddle" hspace="3"></a><br><a href="http://{$SiteUrl}/images/gallery/{$pic.id}.{$pic.ext}" rel="rr" onclick="return jsiBoxOpen(this)" title="{$pic.alt_text}"><img src="http://{$SiteUrl}/images/gallery/s_{$pic.id}.{$pic.ext}" border="1" alt="{$pic.alt_text}" width="{$pic.s_w}" height="{$pic.s_h}"></a>
</li>
{/foreach}
</ul>
<div style="clear: both"></div>
<br>
<button onclick="return saveOrder();" class="btn">Сохранить порядок изображений</button><br>
С отмеченными: <input type="submit" value="Удалить" class="btn"> <button onclick="return CopyImages()" class="btn">Скопировать</button>
</form>
{/if}
<br>
<hr>
<br><br>
{if $id neq null}
	{gallery action="GETGAL" id="$id" varname="gal"}
	<form action="index.php?module=gallery&action=editgal&fixact=1&id={$id}" method="post">
{else}
	<form action="index.php?module=gallery&action=addgal&fixact=1" method="post">
{/if}
	<table border="0" cellpadding="0" cellspacing="2">
	<tr><td></td><td><input type="submit" value="Сохранить изменения" class="btn" checked></td></tr>
	<tr><td width="20%">Название</td><td width="*"><input type="text" name="name" size="30" maxlength="255" value="{$gal.name}" style="width: 100%;"></td></tr>
	<tr><td>Описание короткое</td><td><input type="text" name="shortDescription" size="30" maxlength="255" value="{$gal.shortDescription}" style="width: 100%;"></td></tr>
	<tr><td>Описание длинное</td><td>
	<textarea cols="" rows="20" name="description" style="width: 100%">{$gal.description}</textarea></td></tr>
	<tr><td></td><td><input type="submit" value="Сохранить изменения" class="btn" checked="checked"></td></tr>
	</table>
	</form>

</fieldset>
<div id="dlgSelectGallery" title="Выбор галереи изображений"><iframe id="ifrmGallery" src="" style="width: 100%; height: 90%;"></iframe></div>
{literal}
<script>
if (window.opener!=null)
{
	window.opener.PageLoaded(window,'gallery.items');
}
else if (window.parent!=null)
{
	try
	{
		window.parent.PageLoaded(window,'gallery.items');
	}
	catch(e)
	{
	}
}
</script>
{/literal}
</body>
</html>